package logica_de_presentacion;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;

public class Agur extends JInternalFrame implements ActionListener {

	/**
	 * SALIR CON "HASTA PRONTO"
	 */

	private static final long serialVersionUID = 1L;
	private JButton salir;
	private boolean booleanSalir = false;

	public Agur() {

		salir = new JButton("AGUR");
		salir.setMnemonic(KeyEvent.VK_A);
		salir.addActionListener(this);

		this.getContentPane().setLayout(new BorderLayout());
		this.getContentPane().add(salir, BorderLayout.SOUTH);
		JLabel im = cargarImagen();
		this.getContentPane().add(im, BorderLayout.CENTER);

		this.setVisible(true);
		this.pack();

	}

	public JLabel cargarImagen() {

		JLabel hasta = new JLabel();
		ImageIcon tick = createImageIcon("/logica_de_presentacion/imagenes/HASTA_PRONTO.gif");
		hasta.setIcon(tick);
		return hasta;
	}

	/** Returns an ImageIcon, or null if the path was invalid. */
	protected static ImageIcon createImageIcon(String path) {
		java.net.URL imgURL = Button.class.getResource(path);
		if (imgURL != null) {
			return new ImageIcon(imgURL);
		} else {
			System.err.println("Couldn't find file: " + path);
			return null;
		}
	}
	@Override
	public void actionPerformed(ActionEvent e) {

		if ((JButton) e.getSource() == salir) {
			booleanSalir = true;
			this.dispose();
		}
	}

	public boolean getSalir() {
		return booleanSalir;
	}
}